package RabbitUI.filetype;

import java.io.File;
import java.util.Collection;
import java.util.Iterator;

import javax.swing.filechooser.FileFilter;

public class write_file_filter extends FileFilter {
	Collection<String> filetype;
	public write_file_filter(Collection<String> filetyp){
		filetype=filetyp;
	}
	public void addType(String ext){
		filetype.add(ext);
	}
	public boolean accept(File f) {
		if (f.canWrite()){
		if (f.isDirectory()){return true;}
		else {
			String fil=f.getName();
			
			for (Iterator<String> e=filetype.iterator();e.hasNext();){
				if (fil.endsWith(e.next())) return true;
			}
		}
		}
		return false;
		
	}
	public String getDescription() {
		return  filetype.toString();
	}
}
